package com.cssy.xxkj.logic.dao.impl;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.logic.dao.LogicReceptDAO;
import com.cssy.xxkj.logic.entity.LogicReceptDO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2014-10-08
 */
public class LogicReceptDAOImpl extends SqlMapClientDaoSupport implements LogicReceptDAO {

    /**
     * 插入数据
     * @param logicReceptDO
     * @return 插入数据的主键
     */
    public String insertLogicReceptDO(LogicReceptDO logicReceptDO) {
        Object id = getSqlMapClientTemplate().insert("LogicRecept.insert", logicReceptDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicReceptDO
     * @return 查出的记录数
     */
    public Integer countLogicReceptDOByExample(LogicReceptDO logicReceptDO) {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicRecept.countByDOExample", logicReceptDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicReceptDO
     * @return 受影响的行数
     */
    public Integer updateLogicReceptDO(LogicReceptDO logicReceptDO) {
        int result = getSqlMapClientTemplate().update("LogicRecept.update", logicReceptDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicReceptDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicReceptDO> findListByExample(LogicReceptDO logicReceptDO) {
        List<LogicReceptDO> list = getSqlMapClientTemplate().queryForList("LogicRecept.findListByDO", logicReceptDO);
        return list;
    }

    /**
     * 根据主键获取logicReceptDO
     * @param id
     * @return logicReceptDO
     */
    public LogicReceptDO findLogicReceptDOByPrimaryKey(String id) {
        LogicReceptDO logicReceptDO = (LogicReceptDO) getSqlMapClientTemplate().queryForObject("LogicRecept.findByPrimaryKey", id);
        return logicReceptDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicReceptDOByPrimaryKey(String id) {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicRecept.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<LogicReceptDO> find(SearchConditions scs)
			throws DataAccessException {
		List<LogicReceptDO> list = getSqlMapClientTemplate().queryForList("LogicRecept_ex.find", scs);
        return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicRecept_ex.count", scs);
        return count;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().update("LogicRecept_ex.deleteBizRemoved", id);
        return count;
	}

}